<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>

<p>替换 "microsoft" 为 "Javascript" :</p>
<button onclick="myFunction()">点我</button>
<p id="demo">Visit Microsoft!</p>
<script>
function myFunction() {
    var str = document.getElementById("demo").innerHTML; 
    var txt = str.replace(/microsoft/i,"Javascript")
    document.getElementById("demo").innerHTML = txt;
}
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>

<script>
var patt1=new RegExp("e");
/e/.test("The best things in life are free");
document.write(patt1.test("The best things in life are free"));
</script>

</body>
</html>
</body>
</html>